home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieMediadis.py < prev    next >
Text File  |  2008-11-17  |  4KB  |  112 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. # $Id: PluginMovieMediadis.py 1040 2008-11-15 21:13:49Z mikej06 $
  4.  
  5. # Copyright (c) 2005-2007 Vasco Nunes
  6. # You may use and distribute this software under the terms of the
  7. # GNU General Public License, version 2 or later
  8.  
  9. import gutils
  10. import movie,string
  11.  
  12. plugin_name = "Mediadis"
  13. plugin_description = "Entertaining People"
  14. plugin_url = "www.mediadis.com"
  15. plugin_language = _("English")
  16. plugin_author = "Vasco Nunes"
  17. plugin_version = "0.2"
  18.  
  19. class Plugin(movie.Movie):
  20.     def __init__(self, id):
  21.         self.movie_id = id
  22.         self.url = "http://www.mediadis.com/dvd/detail.asp?id=" + str(self.movie_id)
  23.  
  24.     def get_image(self):
  25.         self.image_url = gutils.trim(self.page,"<img src=\"http://www.mediadis.com/pictures/big/", ".jpg\" border=\"0\"")
  26.         self.image_url = "http://www.mediadis.com/pictures/big/" + self.image_url + ".jpg"
  27.  
  28.     def get_o_title(self):
  29.         self.o_title = string.capwords(gutils.trim(self.page,"<b>Original title</b> : ","<br>") )
  30.  
  31.     def get_title(self):
  32.         self.title = self.o_title
  33.  
  34.     def get_director(self):
  35.  
  36.         self.director = gutils.trim(self.page,"<b>Director(s)</b> : ","<br>")
  37.         self.director = string.replace(self.director, " - ", ", ")
  38.         self.director = gutils.strip_tags(self.director)
  39.  
  40.     def get_plot(self):
  41.         self.plot = gutils.trim(self.page,"<td valign=\"top\" align=\"left\">","</td>")
  42.         self.plot = string.strip(self.plot.decode('latin-1'))
  43.         self.plot = string.replace(self.plot,"<br>", " ")
  44.         self.plot = string.replace(self.plot,"<p>", " ")
  45.         self.plot = string.replace(self.plot,"'","_")
  46.         self.plot = string.strip(gutils.strip_tags(self.plot))
  47.  
  48.     def get_year(self):
  49.         self.year = gutils.trim(self.page,"<b>Year</b> : ","<br>")
  50.  
  51.     def get_runtime(self):
  52.         self.runtime = gutils.trim(self.page,"<b>Duration</b> : "," min")
  53.  
  54.     def get_genre(self):
  55.         self.genre = gutils.trim(self.page,"<b>Genres</b> : ","<br>")
  56.         self.genre = string.replace(self.genre," - ",", ")
  57.  
  58.     def get_cast(self):
  59.         self.cast = ""
  60.         self.cast = gutils.trim(self.page,"<b>Actors</b> : ","<br>")
  61.         self.cast = string.replace(self.cast," - ", "\n")
  62.         self.cast = string.strip(gutils.strip_tags(self.cast))
  63.  
  64.     def get_classification(self):
  65.         self.classification = ""
  66.  
  67.     def get_studio(self):
  68.         self.studio = gutils.trim(self.page,"<b>Studio</b> : ","<br>")
  69.  
  70.     def get_o_site(self):
  71.         self.o_site = ""
  72.  
  73.     def get_site(self):
  74.         self.site = ""
  75.  
  76.     def get_trailer(self):
  77.         self.trailer = ""
  78.  
  79.     def get_country(self):
  80.         self.country = gutils.trim(self.page,"<b>Country</b> : ","<br>")
  81.  
  82.     def get_rating(self):
  83.         self.rating = gutils.trim(self.page, "Global rating : <b>","/10</b> ")
  84.         if self.rating:
  85.             self.rating = string.replace(self.rating, ",", ".")
  86.         self.rating = str(float(gutils.clean(self.rating)))
  87.  
  88. class SearchPlugin(movie.SearchMovie):
  89.  
  90.     def __init__(self):
  91.         self.original_url_search    = "http://www.mediadis.com/dvd/search.asp?t=1&kw=";
  92.         self.translated_url_search    = "http://www.mediadis.com/dvd/search.asp?t=1&kw=";
  93.  
  94.     def search(self,parent_window):
  95.         self.open_search(parent_window)
  96.         self.sub_search()
  97.         return self.page
  98.  
  99.     def sub_search(self):
  100.         self.page = gutils.trim(self.page,"Click to sort out", "Result of your research on the criteria")
  101.  
  102.     def get_searches(self):
  103.         elements = string.split(self.page,"<td rowspan=\"4\" align=\"center\" valign=\"top\" style=\"padding:4px;\">")
  104.         self.number_results = elements[-1]
  105.  
  106.         if (elements[0]<>''):
  107.             for element in elements:
  108.                 self.ids.append(gutils.trim(element,"/dvd/detail.asp?id=","\">"))
  109.                 self.titles.append(gutils.convert_entities(gutils.trim(element,"\" class=\"dvd-search-title\">","</a>")))    
  110.         else:
  111.             self.number_results = 0
  112.